package com.software.seakdream.controller;

import com.software.seakdream.domain.Result;
import com.software.seakdream.entity.ClockInfo;
import com.software.seakdream.service.ClockInfoService;
import com.software.seakdream.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/clock")
public class ClockInfoController {

    @Autowired
    private ClockInfoService clockInfoService;


    @GetMapping("/findClockInfo")
    public Result findClockInfo(String userId) {
        List<ClockInfo> clockInfos = clockInfoService.findClockInfo(userId);
        return ResultUtils.success(clockInfos);
    }

    @PostMapping("/createClockInfo")
    public Result createClockInfo(ClockInfo clockInfo) {
        int clockInfo1 = clockInfoService.createClockInfo(clockInfo);
        return ResultUtils.success(clockInfo1);
    }

    @PostMapping("/editClock")
    public Result editClock(ClockInfo clockInfo) {
        int clockInfo1 = clockInfoService.editClock(clockInfo);
        return ResultUtils.success(clockInfo1);
    }

    @PostMapping("/deleteClockById")
    public void deleteClockById(String clockId) {
        clockInfoService.deleteClock(clockId);
    }
}
